package com.rd.student.dashuju.sunwenzhuo.Test3;

import java.util.concurrent.atomic.AtomicInteger;

public class EnterCave extends Thread {
    AtomicInteger num = new AtomicInteger(1);

    public static void main(String[] args) {

        EnterCave enterCave = new EnterCave();
        new Thread(enterCave, "no.1").start();
        new Thread(enterCave, "no.2").start();
        new Thread(enterCave, "no.3").start();
        new Thread(enterCave, "no.4").start();
        new Thread(enterCave, "no.5").start();
        new Thread(enterCave, "no.6").start();
        new Thread(enterCave, "no.7").start();
        new Thread(enterCave, "no.8").start();
        new Thread(enterCave, "no.9").start();
        new Thread(enterCave, "no.10").start();

       /* Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                try {
                    info1();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, 0, 5000);*/

    }


    @Override
    public void run() {
        cross();
    }
    public synchronized void cross()  {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("第"+num.getAndIncrement()+"个通过隧道的是："+Thread.currentThread().getName());
    }
}

